<?php if(!defined('BASEPATH')) exit('No direct access to this file allowed');
/******************************************************************************\
 *  ComponentLookup
 *
 *  Looks up components in both core and ext folders
 *
 *  Change Log
 *  0.1     -   Initial version of ComponentLookup
 *
 *  @package    core
 *  @author     Ruben Tan
 *  @copyright  Copyright (c) 2008 Rendervault
\******************************************************************************/
class ComponentLookup
{
    /******************************************************************************\
     *  ComponentLookup constructor
     *  @access     public
    \******************************************************************************/
    public function __construct()
    { }
    
    /******************************************************************************\
     *  Returns an array of core components from the system folder
     *
     *  @return     array       A list of core system components in the system
     *                          folder
    \******************************************************************************/
    public function get_core_components()
    {        
        $core_namespace = 'system' . NS . 'common' . NS . 'component' . NS . 'core' . NS;
        $components = array();

        if(!is_dir(CORECOMPATH))
        {
            throw new Exception('Component folder ['.CORECOMPATH.'] does not exists');
        }
        
        //get all class files in the folder
        $component_dir = dir(CORECOMPATH);
        
        while((($file = $component_dir->read())) !== FALSE)
        {
            if($file == '.' || $file == '..' || strpos($file, 'Interface') !== FALSE) continue;
            
            //remove the trailing extension
            $class_name = str_ireplace(EXT, '', $file);
            $components[$class_name] = $core_namespace . $class_name;
        }
        
        return $components;
    }
    
    public function get_component( $component )
    {
        
    }
}